﻿using MediatR;
using S.EarTag.API.Mediator.MediatorCommand;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;

namespace S.EarTag.API.Mediator.MediatorCommandHandler
{
    public class EarTagDeleteCommandHandler : IRequestHandler<EarTagDeleteCommand, bool>
    {
        private readonly IEarTagModelRepository _earTagModelRepository;
        public EarTagDeleteCommandHandler(IEarTagModelRepository earTagModelRepository)
        {
            _earTagModelRepository= earTagModelRepository;
        }
        /// <summary>
        /// 根据Id删除耳标信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<bool> Handle(EarTagDeleteCommand request, CancellationToken cancellationToken)
        {
            return await _earTagModelRepository.DeleteAsync(request.EarTagId);
        }
    }
}
